﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for RoleBusiness
/// </summary>
public class RoleBusiness
{
    RoleData role = null;
	public RoleBusiness()
	{
        role = new RoleData();
		//
		// TODO: Add constructor logic here
		//
	}
    public bool add(RoleEntities item)
    {
        return role.add(item);
    }
    public bool edit(RoleEntities item)
    {
        return role.edit(item);
    }
    public bool delete(int id)
    {
        return role.delete(id);
    }
    public RoleEntities getItem(int id)
    {
        RoleEntities item = null;
        if (id > 0)
        {
            DataTable dt = role.getRole(id);
            if (dt != null)
            {
                DataRow row = dt.Rows[0];
                item = new RoleEntities();
                item._id = int.Parse(row["id"].ToString().Trim());
                item._name = row["name"].ToString();
            }
        }
        return item;
    }
    public System.Collections.ArrayList getRole()
    {
        System.Collections.ArrayList items = new System.Collections.ArrayList();
        DataTable dt = role.getRole(0);
        if (dt != null)
        {
            RoleEntities item = null;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row = dt.Rows[i];
                item = new RoleEntities();
                item._id = int.Parse(row["id"].ToString().Trim());
                item._name = row["name"].ToString();
                items.Add(item);
                item = null;
            }
        }
        return items;
    }

}
